<?php

namespace App\Http\Controllers\UserApi;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Services\Api\DiscountService;

class DiscountController extends BaseController
{
    public function discount_list(DiscountService $discountService){
        $data = $discountService->dicount_list();
        return self::success($data);
    }

    public function discount_info(Request $request,DiscountService $discountService){
        $data = $discountService->discount_info($request->discount_id);
        return self::success($data);
    }

    public function buy_discount(Request $request,DiscountService $discountService){
        $res = $discountService->buy_discount($request->discount_id,auth('api') -> user()->id);

        if(!$res['bool'])self::fail($res['message']);

        return self::success($res);
    }
}
